package com.shanzhu.beadhouse.controller;

import com.shanzhu.beadhouse.common.constant.Constant;
import com.shanzhu.beadhouse.entity.base.Result;
import com.shanzhu.beadhouse.entity.query.*;
import com.shanzhu.beadhouse.service.ServiceProjectService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;

public class ServiceProjectControllerTest {

    @InjectMocks
    private ServiceProjectController controller;

    @Mock
    private ServiceProjectService serviceProjectService;

    @BeforeEach
    public void setUp() {
        MockitoAnnotations.openMocks(this);
    }

    @Test
    public void testGetServiceType() {
        String serviceTypeName = "护理";
        String token = "valid_token";

        Result mockResult = new Result();
        when(serviceProjectService.listServiceType(serviceTypeName)).thenReturn(mockResult);

        Result result = controller.getServiceType(serviceTypeName, token);
        assertEquals(mockResult, result);
    }

    @Test
    public void testPageServiceByKey() {
        PageServiceByKeyQuery query = new PageServiceByKeyQuery();
        String token = "valid_token";
        query.setPageNum(0);
        query.setPageSize(10);
        Result mockResult = new Result();
        when(serviceProjectService.pageServiceByKey(query)).thenReturn(mockResult);

        Result result = controller.pageServiceByKey(query, token);
        assertEquals(mockResult, result);
    }

    @Test
    public void testAddServiceType() {
        OperateServiceTypeQuery operateServiceTypeQuery = new OperateServiceTypeQuery();
        String token = "valid_token";
        operateServiceTypeQuery.setId(1L);
        operateServiceTypeQuery.setName("测试");
        Result mockResult = new Result();
        when(serviceProjectService.addServiceType(operateServiceTypeQuery)).thenReturn(mockResult);

        Result result = controller.addServiceType(operateServiceTypeQuery, token);
        assertEquals(mockResult, result);
    }

    @Test
    public void testDeleteServiceType() {
        Long serviceTypeId = 1L;
        String token = "valid_token";

        Result mockResult = new Result();
        when(serviceProjectService.deleteServiceType(serviceTypeId)).thenReturn(mockResult);

        Result result = controller.deleteServiceType(serviceTypeId, token);
        assertEquals(mockResult, result);
    }

    // 可继续补充其他方法的测试...
}
